﻿using System.IO;
using Framework.Core.Io;
using Framework.Core.Process.Tasks;
using Xunit;

namespace Framework.Tests.Core.Process.Tasks
{
    public class PsZipTest
    {
        [Fact]
        public void Should_validate_command_extract()
        {
            var psZipExtract = new PsZip.PsZipExtract(@"c:\temp", @"c:\temp.zip");

            ValidateName(psZipExtract);
            Assert.Equal(@"-x ""c:\temp"" ""c:\temp.zip""", psZipExtract.Arguments);
        }

        [Fact]
        public void Should_validate_command_compress()
        {
            var psZipCompress = new PsZip.PsZipCompress(@"c:\temp.zip", @"c:\");

            ValidateName(psZipCompress);
            Assert.Equal(@"-z ""c:\temp.zip"" ""c:\""", psZipCompress.Arguments);
        }

        private static void ValidateName(ICommand command)
        {
            Assert.True(File.Exists(command.FileName));
            Assert.False(command.IsNative);
            Assert.Equal("PsZip", command.Name);
            Assert.Equal(@"PsZip.exe", command.FileName);
        }
    }
}
